<?php
class Try_Controller extends Base_Controller
{
    public $restful = true;

    public function get_index()
    {

    }

    public function get_validate()
    {
        $validator = Validator::make(Input::get(), array(
            'house-name' => 'required'
        ));

        if ($validator->fails()) {
            echo $validator->errors->first('house-name');
        } else {
            echo 'Passed';
        }
    }

    public function get_captcha()
    {
        return Captcha::make();
    }

    public function get_rss()
    {
        $items = get_random_rss_news(0);

        foreach ($items as $item) {
            var_dump($item);
        }


        //return Response::make('', 200, array('Content-Type' => 'text/plain'));
    }

    public function get_array()
    {
        $a1 = array(1, 2, 3);
        $a2 = array(3, 4, 5);

        $a3 = array_merge($a1, $a2);

        dd($a3);
    }

    public function get_db()
    {
        $data = Room::group_by('house_id')->get(array('id',DB::raw('max(price) as price')));
        $h = array();
        array_map(function($e) use (&$h) {
            $h[] = $e->id;
        }, $data);

        dd($h);

    }

    public function get_db2()
    {
        $c = Ward::all();
        dd($c);
    }

    public function get_recover()
    {
        return View::make('shared.emails.recover', array(
            'link' => 'test',
            'username' => 'admin',
        ));
    }

    public function get_up()
    {
        return View::make('shared.file');
    }

    public function post_up()
    {

        $filename = time() . '-' . Input::file('upfile.name');
        Input::upload('upfile', 'public/img/tmp', $filename);


        echo $filename;
    }

    public function get_date()
    {
        $d = new DateTime;
        echo $d->format('H:i:s');
    }

    public function get_form()
    {
        return view('shared.test.form');
    }

    public function post_form()
    {
        echo "Your value " . Input::get('t');
    }

    public function get_view()
    {
        $d = action('room@add', array(5, 6));
        dd($d);
    }
}